package com.example.administrator.myapplication.Model;

import com.example.administrator.myapplication.Bean.Notice;
import com.example.administrator.myapplication.Http.Api;
import com.example.administrator.myapplication.Http.RetrofitHelper;
import com.example.administrator.myapplication.Presenter.INoticeListener;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by Administrator on 2019/10/18 0018.
 */

public class NoticeModel implements INoticeModel {

    @Override
    public void getNotices(Notice notice, final INoticeListener iNoticeListener){
        RetrofitHelper retrofitHelper = new RetrofitHelper(Api.Server_Host);
        retrofitHelper.getNotices(notice).enqueue(new Callback<List<Notice>>() {
            @Override
            public void onResponse(Call<List<Notice>> call, Response<List<Notice>> response) {
                iNoticeListener.noticeList(response.body());
            }

            @Override
            public void onFailure(Call<List<Notice>> call, Throwable t) {
                iNoticeListener.error(t.toString());
            }
        });
    }
}
